home *** CD-ROM | disk | FTP | other *** search
- property firstChannel, sectionList, currentSection, dataString, saveEnabled, printEnabled, quitEnabled, savedGameList, nonEmptyGames, trailsSprite, loadGamePopChan, quitButChan, firstNameChan, nameX, nameY, awardsList, quitFlag, quitButObj, helpList
- global gLevelObject, gUserObject, gSceneObject, gSimObject, gGasGaugeObject, gMenuObject, gTruckObject, gVTLgameObject, gVTLobject, gSavePath, gInitObject, gAwardsObject, gHardHatObject, gActorList, gAlbumObject, gLoopGroupObject, gCDpath, gFileSep
-
- on birth me
- set trailsSprite to 15
- set currentSection to 0
- set sectionList to ["3dSite", "Simulator", "MakeAscene", "VTL", "HardHat", "Album", "Awards"]
- set firstChannel to 1
- set firstNameChan to 26
- set nameX to 197
- set nameY to 60
- set quitButChan to 11
- set popupChan to 10
- set loadGamePopChan to 21
- set dataString to EMPTY
- set awardsList to []
- set helpList to [:]
- addProp(helpList, #LogIn, "RCA05HVO")
- addProp(helpList, #menu, "RCA06HVO")
- addProp(helpList, #MakeAscene, "RCA09HVO")
- addProp(helpList, "Sim1", "10HVOR")
- addProp(helpList, "Sim2", "10HVOJ")
- addProp(helpList, "Sim3", "10HVOF")
- addProp(helpList, #VTL, "RCA08HA")
- addProp(helpList, "VTLgame1", "0820HVOR")
- addProp(helpList, "VTLgame2", "0820HVOJ")
- addProp(helpList, "VTLgame3", "0820HVOF")
- addProp(helpList, #JobSite, "RCA07HVO")
- addProp(helpList, #magnifier, "RCA713HV")
- addProp(helpList, #MagNoKeys, "RCA713H2")
- addProp(helpList, #Rotator, "RCA71348")
- addProp(helpList, #QTviewer, "RCA14HVO")
- addProp(helpList, #HardHat, "RCA11HVO")
- addProp(helpList, #Album, "RCA12HVO")
- addProp(helpList, #Culvert, "RCA820HV")
- addProp(helpList, #Ditch, "RCA830HV")
- addProp(helpList, #Dynamite, "RCA1010H")
- addProp(helpList, #Awards, "RCA13HVO")
- return me
- end
-
- on menuButton me, option
- set currentSection to option
- set section to getAt(sectionList, currentSection)
- unpuppetAll()
- puppetPalette("MainPal", 60)
- go("Grass")
- clearAllActors()
- unLoadCast()
- go(the frame + 1)
- if section = "Simulator" then
- set section to section & string(the level of gLevelObject)
- puppetPalette("SimPal", 60)
- updateStage()
- if the firstTime of gSimObject = 0 then
- if the finishedFlag of gSimObject <> 1 then
- predrawSimButtons(gSimObject)
- end if
- end if
- puppetPalette(0)
- else
- if section = "MakeAscene" then
- puppetPalette("ScenePal", 60)
- updateStage()
- predraw(gSceneObject)
- puppetPalette(0)
- else
- if section = "VTL" then
- if the enabled of gVTLgameObject = 1 then
- set the currentItem of gVTLobject to 1
- end if
- set section to section & string(the currentItem of gVTLobject)
- puppetPalette("VTLpal", 60)
- updateStage()
- predraw(gVTLobject)
- puppetPalette(0)
- go(section)
- cleanUp(me)
- go(the frame + 1)
- repeat while soundBusy(1)
- end repeat
- puppetSound(getAt(the nameSoundList of gVTLobject, the currentItem of gVTLobject))
- moveSign(gVTLobject, #down)
- setup(gVTLobject)
- drawHardHat(gVTLobject)
- repeat while soundBusy(1)
- end repeat
- puppetSound(0)
- flushBuffer()
- abort()
- else
- if section = "3dSite" then
- puppetPalette("JobSitePal", 60)
- updateStage()
- puppetPalette(0)
- end if
- end if
- end if
- end if
- go(section)
- cleanUp(me)
- abort()
- end
-
- on cleanUp me
- set gRollAnimButton to EMPTY
- set gLoopGroupObject to EMPTY
- clearAllActors()
- end
-
- on quitButton me, buttonObject
- puppetSprite(the quitButChan of gMenuObject, 1)
- set quitFlag to 1
- set quitButObj to buttonObject
- hideAllActors()
- puppetTransition(51, 1)
- if saveEnabled and gameInProgress(gMenuObject) then
- go("SaveQuit")
- sound playFile 1, gCDpath & "SOUND" & gFileSep & "GLOBAL" & gFileSep & "06VO01G"
- else
- go("WannaQuit")
- sound playFile 1, gCDpath & "SOUND" & gFileSep & "GLOBAL" & gFileSep & "06VO01A"
- end if
- repeat while soundBusy(1)
- end repeat
- puppetSound(0)
- abort()
- end
-
- on flagButtonHandler me, option
- puppetSound(0)
- set currentSection to option + 4
- set section to getAt(sectionList, currentSection)
- unpuppetAll()
- puppetPalette("MainPal")
- go("Grass")
- clearAllActors()
- unLoadCast()
- go(the frame + 1)
- if section = "Awards" then
- puppetPalette("AwardsPal", 60)
- updateStage()
- predraw(gAwardsObject)
- else
- if section = "HardHat" then
- puppetPalette("HardHatPal", 60)
- updateStage()
- predraw(gHardHatObject)
- else
- if section = "Album" then
- puppetPalette("AlbumPal", 60)
- updateStage()
- predraw(gAlbumObject)
- end if
- end if
- end if
- puppetPalette(0)
- go(section)
- cleanUp(me)
- abort()
- end
-
- on listSavedGames me
- set savedGameList to [:]
- repeat with gameNum = 1 to 6
- set filePath to gSavePath & "GAME" & string(gameNum)
- set readObject to FileIO(mnew, "read", filePath)
- if not objectp(readObject) then
- set dataString to "empty"
- set writeObject to FileIO(mnew, "write", filePath)
- writeObject(mWriteString, "empty")
- writeObject(mdispose)
- else
- set dataString to readObject(mReadFile)
- readObject(mdispose)
- end if
- set firstItem to item 1 of dataString
- if firstItem <> "RCAgame" then
- addProp(savedGameList, gameNum, "emptySlot")
- next repeat
- end if
- set index to 5
- set nameString to item index of the dataString of gMenuObject
- set letterQuantity to length(nameString)
- set userName to []
- set letterHoffsets to [0]
- repeat with x = 1 to letterQuantity
- add(userName, value(item index + x of dataString))
- end repeat
- repeat with x = 1 to letterQuantity
- add(letterHoffsets, value(item index + letterQuantity + x of dataString))
- end repeat
- addProp(savedGameList, nameString, [userName, letterHoffsets])
- end repeat
- set nonEmptyGames to []
- repeat with x = 1 to count(savedGameList)
- if getAt(savedGameList, x) <> "emptySlot" then
- add(nonEmptyGames, x)
- end if
- end repeat
- end
-
- on postSavedGames me
- repeat with x = 1 to count(nonEmptyGames)
- set whichGame to getAt(nonEmptyGames, x)
- set gameData to getAt(savedGameList, whichGame)
- set userName to getAt(gameData, 1)
- set letterHoffsets to getAt(gameData, 2)
- set cardCenter to the locH of sprite x
- set nameWidth to getLast(letterHoffsets) + 11
- set locH to cardCenter - integer(nameWidth / 2)
- set locV to the locV of sprite x
- repeat with letterIndex = 1 to count(userName)
- set the castNum of sprite trailsSprite to the firstLetterBmap of gUserObject + getAt(userName, letterIndex) - 1
- set the locH of sprite trailsSprite to locH + getAt(letterHoffsets, letterIndex)
- set the locV of sprite trailsSprite to locV
- updateStage()
- end repeat
- end repeat
- end
-
- on loadGame me
- if (the clickOn <= count(nonEmptyGames)) and not objectp(gRollAnimButton) then
- puppetAll()
- set the locH of sprite loadGamePopChan to the locH of sprite loadGamePopChan + 1000
- puppetTransition(51, 1)
- go(the frame)
- set whichGame to getAt(nonEmptyGames, the clickOn)
- set the oldUserGameNum of gUserObject to whichGame
- set filePath to gSavePath & "GAME" & string(whichGame)
- set readObject to FileIO(mnew, "read", filePath)
- if not objectp(readObject) then
- alert("Sorry, an error occurred trying to read your saved game.")
- exit
- end if
- set dataString to readObject(mReadFile)
- readObject(mdispose)
- set firstItem to item 1 of dataString
- if firstItem <> "RCAgame" then
- alert("Sorry, that's not a valid Road Construction Ahead game.")
- exit
- end if
- set savedLevel to value(item 2 of dataString)
- set index to 3
- set index to loadUserData(gUserObject, index)
- fillName(gUserObject)
- redrawLevelButtons(gLevelObject, savedLevel)
- updateStage()
- if savedLevel > 1 then
- set the gridSize of gSimObject to "Small"
- initSizeVariables(gSimObject)
- initializeGrid(gSimObject)
- end if
- set index to loadAwards(gAwardsObject, index)
- set index to loadAlbum(gAlbumObject, index)
- set index to loadScene(gSceneObject, index)
- set index to loadHardHats(gHardHatObject, index)
- set index to loadVTLgame(gVTLgameObject, index)
- set index to loadSim(gSimObject, index)
- if the firstTime of gSimObject = 0 then
- set index to loadTruck(gTruckObject, index)
- if savedLevel = 3 then
- set index to loadGasGauge(gGasGaugeObject, index)
- set the firstTime of gGasGaugeObject to 0
- end if
- end if
- set the locH of sprite loadGamePopChan to the locH of sprite loadGamePopChan - 1000
- puppetTransition(51, 1)
- go(the frame)
- playSound("RCA-05VO01")
- set the level of gLevelObject to savedLevel
- set the saveEnabled of gMenuObject to 1
- unLoadCast()
- clearAllActors()
- unpuppetAll()
- drawQuitButton(gMenuObject)
- predraw(gMenuObject)
- drawUserLevel(gUserObject)
- go("LocMap")
- abort()
- end if
- flushBuffer()
- end
-
- on writeFile me
- if the oldUserGameNum of gUserObject <> 0 then
- set whichGame to the oldUserGameNum of gUserObject
- else
- repeat with whichGame = 1 to count(savedGameList)
- if getAt(savedGameList, whichGame) = "emptySlot" then
- exit repeat
- end if
- end repeat
- end if
- set filePath to gSavePath & "GAME" & string(whichGame)
- set writeObject to FileIO(mnew, "write", filePath)
- if not objectp(writeObject) then
- exit
- end if
- set savedGame to "RCAgame," & string(the level of gLevelObject) & ","
- set savedGame to savedGame & saveUserData(gUserObject)
- set savedGame to savedGame & saveAwardsData(gAwardsObject)
- set savedGame to savedGame & saveAlbum(gAlbumObject)
- set savedGame to savedGame & saveScene(gSceneObject)
- set savedGame to savedGame & saveHardHats(gHardHatObject)
- set savedGame to savedGame & saveVTLgame(gVTLgameObject)
- set savedGame to savedGame & saveSim(gSimObject)
- if the firstTime of gSimObject = 0 then
- set savedGame to savedGame & saveTruck(gTruckObject)
- if the level of gLevelObject = 3 then
- set savedGame to savedGame & saveGasGauge(gGasGaugeObject)
- end if
- end if
- set savedGame to char 1 to length(savedGame) - 1 of savedGame
- writeObject(mWriteString, savedGame)
- writeObject(mdispose)
- end
-
- on postNamedRoads me
- repeat with x = 1 to count(the namedRoads of gSimObject)
- set whichGame to getAt(nonEmptyGames, x)
- set gameData to getAt(savedGameList, whichGame)
- set userName to getAt(gameData, 1)
- set letterHoffsets to getAt(gameData, 2)
- set locH to the left of sprite x
- set locV to the locV of sprite x
- repeat with letterIndex = 1 to count(userName)
- set the castNum of sprite trailsSprite to the firstLetterBmap of gUserObject + getAt(userName, letterIndex) - 1
- set the locH of sprite trailsSprite to locH + getAt(letterHoffsets, letterIndex)
- set the locV of sprite trailsSprite to locV
- updateStage()
- end repeat
- end repeat
- end
-
- on setPrefs me, booleanString
- set quitEnabled to value(item 1 of booleanString)
- set saveEnabled to value(item 2 of booleanString)
- set printEnabled to value(item 3 of booleanString)
- end
-
- on predraw me
- drawUserName(gUserObject, firstNameChan, nameX, nameY)
- addPeriod(gUserObject)
- end
-
- on help me, buttonObject
- birth(script "Help Parent", buttonObject, #menu)
- end
-
- on drawQuitButton me
- if quitEnabled = 0 then
- removeSprite(quitButChan)
- puppetSprite(quitButChan, 1)
- end if
- end
-
- on gameInProgress me
- set flag to 0
- if anyAwards(gAwardsObject) then
- set flag to 1
- end if
- if the firstTime of gSimObject = 0 then
- set flag to 1
- end if
- if the enabled of gVTLgameObject then
- set flag to 1
- end if
- if count(the stickerList of gSceneObject) > 0 then
- set flag to 1
- end if
- return flag
- end
-